package com.pomr.model.data;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class XTYData implements ObjectData{
	
	public String getXt() {
		return xt;
	}

	public void setXt(String xt) {
		this.xt = xt;
	}

	private String xt;//血糖3

	public static XTYData getInitializtion(String dataStr){
		XTYData xty = new XTYData();
		xty.xt = dataStr.substring(dataStr.length()-3);
		BigDecimal sg = new BigDecimal(xty.xt);
		
		xty.xt = sg.divide(new BigDecimal(18), 1, RoundingMode.HALF_UP).toString();
		return xty;
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("血糖仪：{\n");
		sb.append("	血糖:"+this.xt+"\n");
		sb.append("}\n");
		return sb.toString();
	}
	
	public String toXML(){
		StringBuilder sb = new StringBuilder();
		sb.append("<Option>");
			sb.append("<legendtitle>");
			sb.append("血糖");
			sb.append("</legendtitle>");
			sb.append("<legends>");
				sb.append("<legend>");
					sb.append("<title>");
					sb.append("血糖");
					sb.append("</title>");
					sb.append("<data>");
					sb.append(this.xt);
					sb.append("</data>");
					sb.append("<aver>");
					sb.append("false");
					sb.append("</aver>");
				sb.append("</legend>");
			sb.append("</legends>");
		sb.append("</Option>");
		return sb.toString();
	}
	public static void main(String[] args) {
		BigDecimal sg = new BigDecimal(46);
		String bg = sg.divide(new BigDecimal(18), 1, RoundingMode.HALF_UP).toString();
		System.out.println(bg);
	}
}
